/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package object;

/**
 *
 * @author dheath
 */
public class Point 
{
    private float x;
    private float y;
    private float z;
    private float w;
    
    private Point normal;
    
    public Point(float x, float y, float z, float w)
    {
        this.x = x;
        this.y = y;
        this.z = z;
        this.w = w;
    }
    
    
    public void normalize()
    {
        float len = length();
        
        x = x/len;
        y = y/len;
        z = z/len;
    }
    
    public Point times(float s)
    {
        return new Point(x*s,y*s,z*s,w);
    }
    public float dot(Point p)
    {
        return x*p.getX()+y*p.getY()+z*p.getZ();
    }
    
    public float distance(Point p)
    {
        return (float)Math.sqrt(Math.pow(x-p.getX(), 2)+Math.pow(y-p.getY(), 2)+Math.pow(z-p.getZ(), 2));
    }
    
    public float length()
    {
        return (float)Math.sqrt(x*x+y*y+z*z);
    }
    
    public Point add(float s)
    {
        return new Point(x+s,y+s,z+s,w);
    }
    public Point add(Point p)
    {
        return new Point(x+p.getX(),y+p.getY(),z+p.getZ(),p.getW());
    }
    
    public Point minus(Point p)
    {
        return new Point(x-p.getX(),y-p.getY(),z-p.getZ(),p.getW()); 
    }
    public Point cross(Point p)
    {
        float X = y*p.getZ() - z*p.getY();
        float Y = z*p.getX() - x*p.getZ();
        float Z = x*p.getY() - y*p.getX();
        
        return new Point(X,Y,Z,1);
    }
    
    public Point getNormal()
    {
        return normal;
    }
    public void setNormal(Point n)
    {
        this.normal = n;
    }
    
    public float getX()
    {
        return x;
    }

    public void setX(float x)
    {
        this.x = x;
    }

    public float getY()
    {
        return y;
    }

    public void setY(float y)
    {
        this.y = y;
    }

    public float getZ()
    {
        return z;
    }

    public void setZ(float z)
    {
        this.z = z;
    }

    public float getW()
    {
        return w;
    }

    public void setW(float w)
    {
        this.w = w;
    }
    
    public String toString()
    {
        return "("+x+","+y+","+z+","+w+")";
    }
    
}